package com.example.cargroup.model;

import com.example.cargroup.data.Api;
import com.example.mvvmcommon.mvvm.model.BaseModel;
import com.example.networkmoudel.ChangeFunction;
import com.example.networkmoudel.HttpFactory;
import com.example.networkmoudel.HttpType;
import com.example.networkmoudel.entity.BaseEntity;

import java.util.Map;

import io.reactivex.Observable;

public class ShipAddressModel extends BaseModel {
    //添加
    public Observable<BaseEntity>requestAddAddress(Map<String,Object>map){
        return HttpFactory.getInstance().factory(HttpType.TOKEN)
                .getRetrofit().create(Api.class).requestAddAddress(cteateBody(map))
                .map(new ChangeFunction<>());
    }

    //列表
    public Observable<BaseEntity>requestAddressList(Map<String,Object>map){
        return HttpFactory.getInstance().factory(HttpType.TOKENSIGNTYPE)
                .getRetrofit().create(Api.class)
                .requestAddressList(cteateBody(map))
                .map(new ChangeFunction<>());
    }
    //修改
    public Observable<BaseEntity>requestUpdataAddress(Map<String,Object>map){
        return HttpFactory.getInstance().factory(HttpType.TOKEN)
                .getRetrofit().create(Api.class)
                .requestUpdateAddress(cteateBody(map))
                .map(new ChangeFunction<>());
    }
    //删除
    public Observable<BaseEntity>requestDelAddress(Map<String,Object>map){
        return HttpFactory.getInstance().factory(HttpType.TOKENSIGNTYPE)
                .getRetrofit().create(Api.class)
                .requestDelAddress(cteateBody(map));

    }
}
